#ifndef __LUARUN_H
#define __LUARUN_H

#include "lua.h"
#include "lualib.h"
#include "lauxlib.h" 
#include <board.h>  
#include "shell.h"
#include <string.h>

#define LUA_OK     0
#define LUA_ERROR -1
#define SCRIPTS_PATH "/LuaApp/"
#define OS_FS_PART_NAME "sd0"
typedef int lua_rd_t;

typedef struct _luaL_Reg_os {
    int m_iFunnum;
    char m_cFunname[32];
    luaL_Reg m_stLuafun[FUN_BUFFER_SIZE];
} luaL_Reg_os;

typedef struct _luaL_Rag_All {
    int m_iRegnum;
    luaL_Reg_os m_stReg[REG_NUM_MAX];
} luaL_Rag_All;

extern lua_State *Lua;
extern luaL_Rag_All Lreg;
extern luaL_Reg m[20];

lua_rd_t lua_Add_Reg(const char *_name);
int lua_Add_Fun(lua_rd_t _iNo, const char *_name, lua_CFunction _func);

#define LUA_REG(s) lua_Add_Reg(s)
#define LUA_FUN(n,s,f) lua_Add_Fun(n, s, f)

#endif
